<html>
    <head><title>Admin - Matching</title></head>
    <body>
        <br />
        Admin: <a href="/admin">Setup</a> | <a href="/admin/match">Matching</a>
        <br /><br />
        <form action="/admin/match" method="post">
        <h3>View matchings for {{semesters}}</h3>
        </form>
        
        {% if table %}
        <table border=0>
        <tr><td>
            <form action="/admin/quickSearch" method="post">
                <input type="hidden" name="semesters" value="{{viewSemester}}">
                <input type="text" name="searchString">
                <input type="submit" value="Search"><input type="radio" name="searchFor" value="tas" checked>tas<input type="radio" name="searchFor" value="classes">classes</td>
                <td align="right" valign="top">[ <a href="/admin/advSearch">advanced search</a> ]
            </form>
        </td></tr>
        
        <br />
        
        <form action="/admin/match" method="post">
        <tr><td colspan="2">
            <table border=1>
                <tr><td>Unique</td><td>Course</td><td>Instructor</td><td>TA</td><td>Approved - <input type="checkbox" name="allbox" onClick="checkAllToggle(this.form)">all / none<br></td></tr>
                    {% for course in table %}
                        <tr><td>{{course.unique}}</td><td>{{course.name}}</td><td>{{course.instructor}}</td><td>{{course.taDropDowns}}</td><td>{{course.checkBox}}</td></tr>
                    {% endfor %}                
            </table>
        </td></tr>
        <tr><td>
            <br>
            <input type="hidden" name="viewSemester" value="{{viewSemester}}">
            <input type="submit" name="submit" value="Suggest Matchings">
            <input type="submit" name="submit" value="Save">
            </form>
        </td></tr>
        </table>
        {% else %}
            No sections exist for this semester.
        {% endif %}

    </body>
</html>


<script language="JavaScript" type="text/javascript">
    /* CREDIT: http://www.dustindiaz.com/check-one-check-all-javascript/ */
    function checkAllToggle(fmobj) 
    {
        for (var i=0;i<fmobj.elements.length;i++) 
        {
            var e = fmobj.elements[i];            
            if ( (e.name != 'allbox') && (e.type=='checkbox') ) 
            {
                e.checked = fmobj.allbox.checked;
            }
        }
    }
</script>
